﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;


public partial class BasicBase_SoldierArchive_SoldierUpdataInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindDate();
            // bindDepartment();
            BindData();
         
        }
    }

    void BindData()
    {
        string where = " year=" + YearList.SelectedValue + " and month=" + MonthList.SelectedValue + " order by DepartmentID ";
        DataTable dt = Yipusoft.SoldierArchives.BLL.SoldierUpdate.getDataTable(where);
        GV.DataSource = dt;
        GV.DataBind();
    }

    void bindDepartment()
    {
        string where = " Departmentid like '%000' or  Departmentid like '13121%' or Departmentid like '13131%' ";
        //ddlDepartment.DataSource = Department.GetList(where);
        //ddlDepartment.DataBind();
    }

    void BindDate()
    {
        for (int i = 2009; i < 2050; i++)
        {
            YearList.Items.Add(new ListItem(i + "年", i.ToString()));
        }
        for (int i = 1; i <= 12; i++)
        {
            MonthList.Items.Add(new ListItem(i + "月", i.ToString()));
        }
        YearList.SelectedValue = DateTime.Now.Year.ToString();
        MonthList.SelectedValue = DateTime.Now.Month.ToString();
    }

    protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindData();
    }
    protected void ddlDepartment_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindData();
    }
    protected void YearList_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindData();
    }
    protected void GV_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView dv = e.Row.DataItem as DataRowView;
            Label lblDepartment = e.Row.FindControl("lblDepartment") as Label;
            lblDepartment.Text = Yipusoft.Account.BLL.Department.GetDepartment(dv["DepartmentID"].ToString()).FullName;
            Label ID = (Label)e.Row.FindControl("ID");
            ID.Text = (e.Row.RowIndex + 1).ToString();
            //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F5F5F5',this.style.fontWeight='';");
            //当鼠标离开的时候 将背景颜色还原的以前的颜色 
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");

        }
    }
}
